package com.sfh.cpc.mass.model;

import com.sfh.cpc.com.entity.ENote;
import com.sfh.cpc.com.entity.RspBase;
import com.sfh.cpc.com.entity.RspPage;
import com.sfh.cpc.com.req.ReqMassNote;
import com.sfh.cpc.com.req.ReqVipConsumeWealth;
import com.sfh.lib.exception.HandleException;
import com.sfh.lib.mvvm.service.BaseViewModel;
import com.sfh.lib.rx.IResult;

/**
 * 功能描述: TODO
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/27
 */
public class MassNoteModel extends BaseViewModel implements IResult<RspBase<RspPage<ENote>>> {

    public void vipLookMass(long userId){
        this.execute(new ReqVipConsumeWealth(userId));
    }

    public void pageMassNote(int nowPage, long massId, final int type) {
        this.execute(new ReqMassNote(type, nowPage, massId), this);
    }

    @Override
    public void onSuccess(RspBase<RspPage<ENote>> data) throws Exception {
        if (data.success()) {
            setValue("onPageSuccess", data.getData());
        } else {

            setValue("onPageSuccess");
        }
    }

    @Override
    public void onFail(HandleException e) {
        setValue("onPageSuccess");
    }
}
